%  This file is part of Erlywog.

%  Erlywog is free software: you can redistribute it and/or modify
%  it under the terms of the GNU General Public License as published by
%  the Free Software Foundation, either version 3 of the License, or
%  (at your option) any later version.

%  Erlywog is distributed in the hope that it will be useful,
%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%  GNU General Public License for more details.

%  You should have received a copy of the GNU General Public License
%  along with Erlywog.  If not, see <http://www.gnu.org/licenses/>.

%  Copyright Jasm Sison 2009

%% @doc file to start the blog application when yaws is launched
-module(bloggo).
-export([boot/0,boot/1,start/0]).

boot()      -> boot(true).
boot(false) -> compile();
boot(true)  -> mysql_start(), compile().

mysql_start() ->
    erlydb:start(mysql, [{hostname, "localhost"},
      {username, "blog-writer"},
      {password, "password"},
      {database, "erlywog_blog"}]).

compile() ->
    Paths =
    [
      "/home/user/erlywog/blog"
      , "/home/user/erlywog/magic"
    ]
    , Options = [
        {erlydb_driver, mysql}
      , {auto_compile, true}
%      , {auto_compile_exclude, "/ext"}
    ]
    , [ erlyweb:compile(Addr, Options) || Addr <- Paths ].

start() -> boot().
